<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<title>管理平台</title>
<script type="text/javascript">


</script>
<jsp:include page="../../include/header.jsp"></jsp:include>
</head>
<body>
	<div id="wrapper">
	
			<div class="row">
				<div class="col-lg-12">
					<h1 class="page-header">商品列表</h1>
				</div>
			</div>

			<div class="row">
				<div class="col-lg-12">
					<div class="row">
						<div class="col-lg-6">
							<div class="text-muted single-line-text pull-left">
								共 <font color="#428bca" id="dataCount1">0</font> 条记录
								<h2>数据列表</h2>
							</div>
						</div>
						<div class="pull-right">



							<button type="button"
								onclick="javascript:window.location.reload()"
								class="btn btn-success btn-lg btn-refresh">
								<span class="fa fa-refresh fa-lg"></span>
							</button>
							<button type="button" class="btn btn-success"
								onclick='toAddGoods(${slid})'>
								<span class="fa fa-plus"></span> 添加
							</button>
							<button type="button" class="btn btn-success" onclick="doSort()">
								<span class="fa fa-save"></span> 保存修改
							</button>

						</div>
					</div>
					<div class="table-responsive">
						<form id="sortForm" action="${BASE_PATH}/spike/list/doSort"
							method="post">
							<!-- <input type="hidden" name="sortKey" value="orderNo/"> <input
								type="hidden" name="money" value="spikePrice/"> <input
								type="hidden" name="count" value="spikeNum/"> <input
								type="hidden" name="lim" value="urv/"> -->
							<table id="dataTable" class="table table-striped table-hover">
								<thead>
									<tr>
										<!-- <td><input type="checkbox" id="selectAll" onclick="select();" ><span>全选</span></td> -->
										<th>编号</th>
										<th>商品名称</th>
										<th>货号</th>
										<th>商品价格</th>
										<th>秒杀价格</th>
										<th>秒杀数量</th>
										<th>剩余数量</th>
										<th>秒杀提醒</th>
										<th>限购数量</th>
										<th>排序</th>
										<th>操作</th>
									</tr>
								</thead>
								<tbody id="dataList1"></tbody>
							</table>
						</form>
					</div>
					<div class="row">
						<div class="col-lg-12">
							<ul id="dataPagination1" class="pagination-sm pull-right"></ul>
						</div>
					</div>
				</div>
			</div>
		
	</div>
	<jsp:include page="../../include/javascripts.jsp"></jsp:include>
	<!-- 异步加载下一页数据后，用模板渲染 -->
	<!-- <td><input type="checkbox" id="checkcode" name="checkcode" value="{{item.id}}" ></td> -->
	<script type="text/html" id="dataTpl1">
	{{each list as item}}
	<tr id="item{{item.id}}" data-id="{{item.id}}">
		
		<td>{{item.id}}</td>
		<td>{{item.name}}</td>
		<td>{{item.goodsNum}}</td>
		<td>{{item.sellPrice}}</td>
		<td><input name="spikePrice/{{item.id}}" value="{{item.spikePrice}}" class="form-control"> </td>
		<td><input name="spikeNum/{{item.id}}" value="{{item.spikeNum}}" class="form-control"></td>
		<td>{{item.spikeLeft}}</td>
		<td>{{item.spikeRemind}}</td>
		<td><input name="limited/{{item.id}}" value="{{item.limited}}" class="form-control"></td>
		<td><input name="orderNo/{{item.id}}" value="{{item.orderNo}}" size="3" class="order form-control width50" maxLenth="3" required></td>
 		<td><button type="button" class="btn btn-sm btn-danger btn-simple" onclick="toDeleteGoods('{{item.id}}')" title="删除"><span class="fa fa-remove fa-lg">删除</span></button> 
</td>
	</tr>
	{{/each}}
</script>
	<script type="text/javascript">

		 var dataPaginator;
		$(function() {
			var params={
					pageSize:10,
					sid:$("#sid").val()
			};
			if (dataPaginator) {
				dataPaginator.destroy();
			}
			dataPaginator = Kit.pagination("#dataPagination1",
					"${BASE_PATH}/spike/list/page2",params, function(result) {
						//设置显示最新的数据数量
						$("#dataCount1").html(result.object.totalRow);
						//根据模板渲染数据并填充
						$("#dataList1").empty().append(
								template("dataTpl1", result.object));
					});
		}); 
	/* 	{closable:false, size:'size-wide:300px'} */
		var addGoodsDialog;
		function toAddGoods(id) {
			addGoodsDialog = Kit.dialog("添加商品","${BASE_PATH}/spike/list/toAddGoods/"+id).open();
		
		
		
		/* addGoodsDialog.confirm("wdww?",function(result){
			if(result){
				window.location.reload();
				}	
			
			}); */
		}
		/* $(document).ready(function(){
			
			$("#").dialog({
				close:function(event,ui){
					window.location.reload();
				}			
				});
			});	 */
		function toDeleteGoods(id) {
			Kit.confirm("提示", "您确定要删除这条数据吗？", function() {
				$.post("${BASE_PATH}/spike/list/doDeleteGoods/"+id,function(
						result) {
					$("#item" + id).remove();
				});
			});
		}	
			

			
		 function doSort() {
			
			$("#sortForm").ajaxSubmit({
				success : function(data) {
					switch (data.flag) {
					case -1:
						Kit.alert("网络繁忙...，请重试");
						return;
					case 1:
						Kit.alert("秒杀价格只能是非负浮点数");
						return;
					case 2:
						Kit.alert("秒杀数量只能是正整数");
						return;
					case 3:
						Kit.alert("限购量只能填正整合")
						return;
						
					case 0:
						window.location.reload();
					}
				}
			});
		} 
		/* $(function() {
			$("#selectAll").click(function() {
				$(":checkbox[name='checkcode']").prop("checked", this.checked);
			});
		});

		$(this).prop("checked",obj[$(this).val()]); */

		
	</script>
	<input type="hidden" id="sid" name="sid" value="${slid}">
</body>
</html>